To see if we can make exclude gates.

In [1]:
import galaxy_tests
import ResolvedStellarPops as rsp
import ResolvedStellarPops.PadovaTracks as pc
import os
import numpy as np

In [2]:
reload(pc)


Out[2]:
<module 'ResolvedStellarPops.PadovaTracks' from '/home/rosenfield/research/python/ResolvedStellarPops/PadovaTracks.pyc'>

In [2]:
tracks_base = '/home/rosenfield/research/stel_evo/CAF09_S12D_NS/'
prefixs = ['S12D_NS_Z0.0001_Y0.249',
           'S12D_NS_Z0.0002_Y0.249',
           'S12D_NS_Z0.0005_Y0.249',
           'S12D_NS_Z0.001_Y0.25',
           'S12D_NS_Z0.002_Y0.252',
           'S12D_NS_Z0.004_Y0.256',
           'S12D_NS_Z0.006_Y0.259',
           'S12D_NS_Z0.008_Y0.263',
           'S12D_NS_Z0.014_Y0.273',
           'S12D_NS_Z0.017_Y0.279',
           'S12D_NS_Z0.01_Y0.267',
           'S12D_NS_Z0.02_Y0.284',
           'S12D_NS_Z0.03_Y0.302',
           'S12D_NS_Z0.04_Y0.321',
           'S12D_NS_Z0.05_Y0.339',
           'S12D_NS_Z0.06_Y0.356']

# only need to do this once.
#[pc.quick_color_em(tracks_base, prefix, photsys='wfc3snap') for prefix in prefixs]

In [26]:
input_file = '/home/rosenfield/research/stel_evo/parsec2match/parsec2match.inp'
infile = pc.default_params(rsp.fileIO.load_input(input_file))
infile['masses'] = [7]
infile['track_search_term'] = '*snap'
del infile['prefixs']
infile['do_interpolation'] = False
track_sets = [pc.TracksForMatch(prefix=p, **infile) for p in prefixs]


Some errors were detected !
    Line #790 (got 573 columns instead of 83)
    Line #791 (got 573 columns instead of 83)
    Line #792 (got 363 columns instead of 83)
    Line #793 (got 153 columns instead of 83)
    Line #794 (got 153 columns instead of 83)
Some errors were detected !
    Line #857 (got 573 columns instead of 83)
    Line #858 (got 363 columns instead of 83)
    Line #859 (got 573 columns instead of 83)
    Line #860 (got 153 columns instead of 83)
    Line #861 (got 153 columns instead of 83)
Some errors were detected !
    Line #609 (got 993 columns instead of 83)
    Line #610 (got 573 columns instead of 83)
    Line #611 (got 153 columns instead of 83)
    Line #612 (got 153 columns instead of 83)
Some errors were detected !
    Line #575 (got 573 columns instead of 83)
    Line #576 (got 993 columns instead of 83)
    Line #577 (got 223 columns instead of 83)
    Line #578 (got 153 columns instead of 83)
    Line #579 (got 153 columns instead of 83)
Some errors were detected !
    Line #556 (got 503 columns instead of 83)
    Line #557 (got 1063 columns instead of 83)
    Line #558 (got 293 columns instead of 83)
    Line #560 (got 153 columns instead of 83)
    Line #925 (got 223 columns instead of 83)
    Line #926 (got 293 columns instead of 83)
    Line #927 (got 153 columns instead of 83)
    Line #929 (got 153 columns instead of 83)
    Line #933 (got 293 columns instead of 83)
    Line #934 (got 363 columns instead of 83)
    Line #935 (got 293 columns instead of 83)
    Line #936 (got 153 columns instead of 83)
    Line #944 (got 223 columns instead of 83)
    Line #945 (got 153 columns instead of 83)
    Line #946 (got 153 columns instead of 83)
    Line #954 (got 153 columns instead of 83)
    Line #961 (got 153 columns instead of 83)
Some errors were detected !
    Line #546 (got 1063 columns instead of 83)
    Line #547 (got 293 columns instead of 83)
    Line #548 (got 433 columns instead of 83)
    Line #549 (got 223 columns instead of 83)
Some errors were detected !
    Line #550 (got 153 columns instead of 83)
    Line #551 (got 433 columns instead of 83)
    Line #552 (got 223 columns instead of 83)
    Line #553 (got 783 columns instead of 83)
    Line #554 (got 223 columns instead of 83)
    Line #557 (got 153 columns instead of 83)
Some errors were detected !
    Line #555 (got 1413 columns instead of 83)
    Line #556 (got 293 columns instead of 83)
Some errors were detected !
    Line #561 (got 783 columns instead of 83)
    Line #562 (got 713 columns instead of 83)
    Line #563 (got 223 columns instead of 83)
    Line #564 (got 153 columns instead of 83)
Some errors were detected !
    Line #557 (got 1343 columns instead of 83)
    Line #558 (got 293 columns instead of 83)
    Line #559 (got 153 columns instead of 83)
    Line #560 (got 153 columns instead of 83)
Some errors were detected !
    Line #564 (got 153 columns instead of 83)
    Line #565 (got 1483 columns instead of 83)
    Line #567 (got 223 columns instead of 83)
    Line #568 (got 153 columns instead of 83)
    Line #569 (got 153 columns instead of 83)
Some errors were detected !
    Line #561 (got 1623 columns instead of 83)
    Line #562 (got 223 columns instead of 83)
    Line #563 (got 153 columns instead of 83)
    Line #2219 (got 363 columns instead of 83)
    Line #2220 (got 153 columns instead of 83)
    Line #2221 (got 153 columns instead of 83)
    Line #2222 (got 153 columns instead of 83)
    Line #2223 (got 153 columns instead of 83)
    Line #2224 (got 153 columns instead of 83)
    Line #2226 (got 153 columns instead of 83)
    Line #2228 (got 153 columns instead of 83)
    Line #2231 (got 153 columns instead of 83)
    Line #2233 (got 153 columns instead of 83)
    Line #2238 (got 153 columns instead of 83)
Some errors were detected !
    Line #560 (got 1553 columns instead of 83)
    Line #561 (got 293 columns instead of 83)
    Line #562 (got 153 columns instead of 83)
    Line #563 (got 153 columns instead of 83)
Some errors were detected !
    Line #560 (got 1553 columns instead of 83)
    Line #562 (got 223 columns instead of 83)
    Line #563 (got 153 columns instead of 83)

In [27]:
zs = np.array([track_sets[i].tracks[0].Z for i in range(len(track_sets))])

In [28]:
tracks = [t.tracks[0] for t in track_sets]

In [29]:
_ = [t.ptcri.load_sandro_eeps(t) for t in tracks]

In [15]:
# I wrote this thinking I should only cut color, mag brighter than the weighted average
# metallicity in the last 20 Myr. If I did that, it would simply bias match to use lower 
# metallicities to fit the upper MS. Instead, the entire region should be cut,
# which means use the lowest metallicity track to cut the stars.
def match_metallicities():
    met_dict = {}
    sfh_dir = '/home/rosenfield/research/TP-AGBcalib/SNAP/data/sfh/'
    sfh_files = rsp.fileIO.get_files(sfh_dir, '*dat')
    for i in range(len(sfh_files)):
        target = sfh_files[i].split('_')[2]
        age, sfr, z = np.genfromtxt(sfh_files[i], unpack=True)
        age = np.array(age)[1::8]
        sfr = np.array(sfr)[1::8]
        z = np.array(z)[1::8]
        young, = np.nonzero(age <= 7.3)
        met_dict[target] = np.average(z[young], weights=sfr[young])
    met_dict['M81-DEEP'] = 0.03
    #met_dict['ESO540-030'] = 
    return met_dict

met_dict = match_metallicities()

In [7]:
fits_src='/home/rosenfield/research/TP-AGBcalib/SNAP/data/angst_no_trim'

In [8]:
fits_files = rsp.fileIO.get_files(fits_src, '*fits')

In [9]:
gal_kw = {'hla': True, 'photsys': 'wfc3snap', 'band': 'opt', 'angst': True,
          'filetype': 'fitstable'}

In [10]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [30]:
# one big plot
fig, (axs) = rsp.graphics.GraphicsUtils.setup_multiplot(len(fits_files), figsize=(30,30))
axs = np.squeeze(np.concatenate(axs))

for i, fits_file in enumerate(fits_files):
    gal = rsp.Galaxies.galaxy(fits_file, **gal_kw)
    gal.plot_cmd(gal.color, gal.mag2, levels=3, threshold=100, ax=axs[i])
    gal.photsys = 'wfc3snap'
    gal.decorate_cmd(ax=axs[i])
    # plot all the tracks... could call met_dict here if only one track is wanted
    for track in tracks:
        # cut anything before MS.
        ims = track.ptcri.sptcri[4]
        # Mag 2 mag, this can be done in plot track, but I wasn't using DiagTracks at first.
        Mag1 = track.data[gal.filter1][ims:]
        Mag2 = track.data[gal.filter2][ims:]

        mag1 = rsp.astronomy_utils.Mag2mag(Mag1, gal.filter1, 'wfc3snap',
                                       filter1=gal.filter1, filter2=gal.filter2,
                                       target=gal.target)
        mag2 = rsp.astronomy_utils.Mag2mag(Mag2, gal.filter2, 'wfc3snap', 
                                       filter1=gal.filter1, filter2=gal.filter2,
                                       target=gal.target)
        color = mag1 - mag2
        track_sets[0].plot_track(track, '', '', xdata=color, ydata=mag2,
                                 clean=False, ax=axs[i],
                                 plt_kw={'lw':3, 'color':'k'})
        track_sets[0].plot_track(track, '', '', xdata=color, ydata=mag2,
                                 clean=False, ax=axs[i],
                                 plt_kw={'lw':2, 'color':'grey'})


SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
M81_DEEP using M81-DEEP
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
NGC3077_PHOENIX using NGC3077-PHOENIX
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
SN_NGC2403_PR using NGC2403-DEEP
WHOOPS ESO540-030

In [25]:
'''
# if met_dict is used...
    tget = gal.target.upper()
    if 'SN' in tget:
        tget = 'NGC2403-DEEP'
    if '300' in tget:
        tget = 'NGC0300-WIDE1'
    if 'UGC4305-1' in tget:
        tget = 'UGC-4305-1'
    if 'UGC4305-2' in tget:
        tget = 'UGC-4305-2'
    if 'NGC404-DEEP' in tget:
        tget = 'NGC0404-DEEP'
    if '4459' in tget:
        tget = 'UGC-04459'
    if '5139' in tget:
        tget = 'UGC-5139'
    try:
        z = float(met_dict[tget])
        zclose = np.argmin(abs(z-zs))
        #print z, zs[zclose]
        track = tracks[-1]
    except KeyError:
        print 'WHOOPS', tget
'''


Out[25]:
10.0